[6.x] Return the fallback when reading a file from a disk that throws - #15185
Open
duncanmcclean wants to merge 2 commits into
Open
[6.x] Return the fallback when reading a file from a disk that throws#15185duncanmcclean wants to merge 2 commits into
duncanmcclean wants to merge 2 commits into
Conversation
`AbstractAdapter::get()` only caught `FileNotFoundException`, which `Storage` disks stopped throwing in Laravel 9. On a disk configured with `throw`, `League\Flysystem\UnableToReadFile` escaped instead, so `Asset::meta()` never received its fallback and missing meta files were never generated. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…s in use Covers the other route to the same missing meta read: the indexer calls `lastModified()` during `$store->save()`, before `AssetRepository::save()` writes the meta file. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request fixes an issue where a missing asset meta file would break the asset browser on any disk configured with
'throw' => true, withUnable to read file from location: .meta/example.jpg.yaml.This was happening because
Statamic\Filesystem\AbstractAdapter::get()only caughtIlluminate\Contracts\Filesystem\FileNotFoundException, whichStoragedisks stopped throwing in Laravel 9.On a disk with
throwenabled, Laravel rethrowsLeague\Flysystem\UnableToReadFileinstead, so the exception escapedget()rather than returning the fallback.Asset::meta()relies on that fallback to know it needs to generate a missing meta file, so meta was never generated and the whole listing went down. It's not S3-specific — it affects any disk withthrowenabled, which is why it's also been reported on SFTP.This PR fixes it by catching
UnableToReadFileas well. TheFileNotFoundExceptioncatch has to stay:AbstractAdapteris shared byFlysystemAdapter, which wraps aStoragedisk, andFilesystemAdapter, which wrapsIlluminate\Filesystem\Filesystem— and the latter still throws it today.There are two routes to the same failed read, and this PR covers both with tests:
Asset::meta()last_modifiedindex is in use hits it via the indexer, which callslastModified()during$store->save()— beforeAssetRepository::save()writes the meta file.Fixes #8641
Fixes #11961
Related: #11966